package com.leetcode.problems397;


/**
 * https://leetcode-cn.com/problems/merge-two-sorted-lists/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {


    public int integerReplacement(int n) {
        if(n == 1){
            return 0;
        }
        if(n % 2 == 0){
            return integerReplacement(n / 2) + 1;
        }
        if(n == Integer.MAX_VALUE){
            return integerReplacement(n - 1);
        }
        return Math.min(integerReplacement(n + 1), integerReplacement(n - 1)) + 1;
    }
    public static void main(String[] args) {
        System.out.println(new Solution().integerReplacement(6));
    }
}
